﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Text;
using netDxf;
using netDxf.Blocks;
using netDxf.Collections;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Objects;
using netDxf.Tables;
using netDxf.Units;
using Attribute = netDxf.Entities.Attribute;
using Image = netDxf.Entities.Image;
using Point = netDxf.Entities.Point;
using Trace = netDxf.Entities.Trace;
using System.Threading;

namespace TestDxfDocument
{
    class CartridgesForIndexableInserts
    {
        public static void CartridgesForIndexableInsert(Dictionary<string, Object> data)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
            //作图
            //参数
            string path = Convert.ToString(data["path"]);
            double slf = Convert.ToDouble(data["lf"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0)
            {
                if (slf < 67)
                {
                    scale = 4.0;
                }
                else if (slf < 90)
                {
                    scale = 3.0;
                }
                else if (slf < 134)
                {
                    scale = 2.0;
                }
                else if (slf < 178)
                {
                    scale = 1.5;
                }
                else if (slf < 268)
                {
                    scale = 1.0;
                }
                else if (slf < 357)
                {
                    scale = 0.75;
                }
                else
                {
                    scale = 0.5;
                }
            }
            double pi = Math.PI;
            string ceatc = Convert.ToString(data["ceatc"]);//选项E端切、S侧切
            string thsc = Convert.ToString(data["thsc"]);//选项S直头、O偏头
            string sc = Convert.ToString(data["sc"]);//选项T三角形、CDEMVS菱形、O非标准菱形
            double epsr = Convert.ToDouble(data["epsr"]) * pi / 180;
            if (sc == "T")
            {
                epsr = 60 * pi / 180;
            }
            if (sc == "C")
            {
                epsr = 80 * pi / 180;
            }
            if (sc == "D")
            {
                epsr = 55 * pi / 180;
            }
            if (sc == "E")
            {
                epsr = 75 * pi / 180;
            }
            if (sc == "M")
            {
                epsr = 86 * pi / 180;
            }
            if (sc == "V")
            {
                epsr = 35 * pi / 180;
            }
            if (sc == "S")
            {
                epsr = 90 * pi / 180;
            }
            double dk = Convert.ToDouble(data["dk"]) * scale;
            double k = Convert.ToDouble(data["k"]) * scale;
            double td = Convert.ToDouble(data["td"]) * scale;
            double asp = Convert.ToDouble(data["asp"]) * scale;
            double hf = Convert.ToDouble(data["hf"]) * scale;
            double h = Convert.ToDouble(data["h"]) * scale;
            double b = Convert.ToDouble(data["b"]) * scale;
            double dah = Convert.ToDouble(data["dah"]) * scale;
            double mhd = Convert.ToDouble(data["mhd"]) * scale;
            double mhd2 = Convert.ToDouble(data["mhd2"]) * scale;
            double hea = Convert.ToDouble(data["hea"]) * pi / 180;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double mhh = Convert.ToDouble(data["mhh"]) * scale;
            double lf = Convert.ToDouble(data["lf"]) * scale;
            double lh = lf - ls;
            double wf = Convert.ToDouble(data["wf"]) * scale;
            double ic = Convert.ToDouble(data["ic"]) * scale;
            double kapr = Convert.ToDouble(data["kapr"]) * pi / 180;
            double s = Convert.ToDouble(data["s"]) * scale;
            double an = Convert.ToDouble(data["an"]) * pi / 180;
            double mha = Convert.ToDouble(data["mha"]) * pi / 180;
            if (hf < 16 * scale)
            {
                mha = 20 * pi / 180;
            }
            double adjrg = Convert.ToDouble(data["adjrg"]) * scale;
            double isframe = Convert.ToDouble(data["isframe"]);
            //坐标
            //主视图
            if (thsc == "O")//偏头
            {
                if (ceatc == "E")//端切
                {
                    if (sc == "T")//三角形刀片
                    {

                    }
                    else//菱形刀片
                    {
                        double l = ic / Math.Sin(epsr);
                        Vector2 v1 = new Vector2(b / 2 - dk / 2, -dk / 4);
                        Vector2 v2 = new Vector2(b / 2 + dk / 2, v1.Y);
                        Vector2 v3 = new Vector2(v2.X, -k);
                        Vector2 v4 = new Vector2(b / 2 + td / 2, v3.Y);
                        Vector2 v5 = new Vector2(v4.X, -asp);
                        Vector2 v6 = new Vector2(b, v5.Y);
                        Vector2 v7 = new Vector2(v6.X, -ls);
                        Vector2 v12 = new Vector2(wf, -lf);
                        Vector2 v0 = new Vector2(v12.X - s * Math.Tan(an) * Math.Cos(pi - kapr - epsr / 2) / Math.Sin(epsr / 2), v12.Y + s * Math.Tan(an) * Math.Sin(pi - kapr - epsr / 2) / Math.Sin(epsr / 2));
                        Vector2 v11 = new Vector2(v12.X + l * Math.Cos(kapr), v12.Y + l * Math.Sin(kapr));
                        Vector2 v13 = new Vector2(v12.X - l * Math.Cos(pi - kapr - epsr), v12.Y + l * Math.Sin(pi - kapr - epsr));
                        Vector2 v10 = new Vector2(v11.X - l * Math.Cos(pi - kapr - epsr), v11.Y + l * Math.Sin(pi - kapr - epsr));
                        Vector2 v9 = new Vector2(v11.X - s * Math.Tan(an) * Math.Cos(pi - kapr - epsr) / Math.Sin(epsr), v11.Y + s * Math.Tan(an) * Math.Sin(pi - kapr - epsr) / Math.Sin(epsr));
                        Vector2 v14 = new Vector2(v13.X + s * Math.Tan(an) * Math.Cos(kapr) / Math.Sin(epsr), v13.Y + s * Math.Tan(an) * Math.Sin(kapr) / Math.Sin(epsr));
                        Vector2 v8 = new Vector2(((v0.X * Math.Tan(kapr) * Math.Tan(hea) + v7.X + v7.Y * Math.Tan(hea)) - v0.Y * Math.Tan(hea)) / (1 + Math.Tan(kapr) * Math.Tan(hea)), (((v0.X * Math.Tan(kapr) * Math.Tan(hea) + v7.X + v7.Y * Math.Tan(hea)) - v0.Y * Math.Tan(hea)) / (1 + Math.Tan(kapr) * Math.Tan(hea)) - v0.X) * Math.Tan(kapr) + v0.Y);
                        Vector2 v15 = new Vector2(0, v0.Y + v0.X * Math.Tan(pi - kapr - epsr));
                        Vector2 v16 = new Vector2(0, v8.Y);
                        Vector2 v17 = new Vector2(0, v7.Y);
                        Vector2 v18 = new Vector2(0, v6.Y);
                        Vector2 v19 = new Vector2(b / 2 - td / 2, v5.Y);
                        Vector2 v20 = new Vector2(v19.X, v4.Y);
                        Vector2 v21 = new Vector2(v1.X, v3.Y);
                        //线段
                        Vector2[] Line1 = { v1, v2 };
                        fun.drawBLine(dxf, Line1, 0.3, contour);
                        Vector2[] Line2 = { v2, v3 };
                        fun.drawBLine(dxf, Line2, 0.3, contour);
                        Vector2[] Line3 = { v3, v21 };
                        fun.drawBLine(dxf, Line3, 0.3, contour);
                        Vector2[] Line4 = { v21, v1 };
                        fun.drawBLine(dxf, Line4, 0.3, contour);
                        Vector2[] Line5 = { v4, v5 };
                        fun.drawBLine(dxf, Line5, 0.3, contour);
                        Vector2[] Line6 = { v19, v20 };
                        fun.drawBLine(dxf, Line6, 0.3, contour);
                        Vector2[] Line7 = { v6, v18 };
                        fun.drawBLine(dxf, Line7, 0.3, contour);
                        Vector2[] Line8 = { v6, v7 };
                        fun.drawBLine(dxf, Line8, 0.3, contour);
                        Vector2[] Line9 = { v7, v17 };
                        fun.drawBLine(dxf, Line9, 0.3, contour);
                        Vector2[] Line10 = { v7, v8 };
                        fun.drawBLine(dxf, Line10, 0.3, contour);
                        Vector2[] Line11 = { v8, v16 };
                        fun.drawBLine(dxf, Line11, 0.3, contour);
                        Vector2[] Line12 = { v8, v9 };
                        fun.drawBLine(dxf, Line12, 0.3, contour);
                        Vector2[] Line13 = { v10, v11 };
                        fun.drawBLine(dxf, Line13, 0.3, contour);
                        Vector2[] Line14 = { v11, v12 };
                        fun.drawBLine(dxf, Line14, 0.3, contour);
                        Vector2[] Line15 = { v12, v13 };
                        fun.drawBLine(dxf, Line15, 0.3, contour);
                        Vector2[] Line16 = { v13, v10 };
                        fun.drawBLine(dxf, Line16, 0.3, contour);
                        Vector2[] Line17 = { v14, v15 };
                        fun.drawBLine(dxf, Line17, 0.3, contour);
                        Vector2[] Line18 = { v15, v18 };
                        fun.drawBLine(dxf, Line18, 0.3, contour);
                        LwPolyline Arc1 = new LwPolyline();
                        Arc1.Vertexes.Add(new LwPolylineVertex(v2));
                        Arc1.Vertexes.Add(new LwPolylineVertex(v1));
                        Arc1.Vertexes[0].Bulge = dk / 2 / (v2.X - v1.X);
                        fun.PolyFill(dxf, Arc1, 0.3, contour);
                        if (hf < 16 * scale)
                        {
                            Vector2 v22 = new Vector2((b - mhh * Math.Tan(mha)) / (1 + Math.Tan(mha) * Math.Tan(mha)) - (dah - adjrg) / 2, -mhd + adjrg / 2);
                            Vector2 v23 = new Vector2(v22.X + dah - adjrg, v22.Y);
                            Vector2 v24 = new Vector2(v23.X, -mhd - adjrg / 2);
                            Vector2 v25 = new Vector2(v22.X, v24.Y);
                            Vector2 v26 = new Vector2(v22.X * 2 + dah - adjrg - v6.X, v7.Y);
                            Vector2 v27 = new Vector2(v26.X, v6.Y);
                            Vector2[] Line19 = { v22, v25 };
                            fun.drawBLine(dxf, Line19, 0.3, contour);
                            Vector2[] Line20 = { v23, v24 };
                            fun.drawBLine(dxf, Line20, 0.3, contour);
                            LwPolyline Arc2 = new LwPolyline();
                            Arc2.Vertexes.Add(new LwPolylineVertex(v23));
                            Arc2.Vertexes.Add(new LwPolylineVertex(v22));
                            Arc2.Vertexes[0].Bulge = 1;
                            fun.PolyFill(dxf, Arc2, 0.3, contour);
                            LwPolyline Arc3 = new LwPolyline();
                            Arc3.Vertexes.Add(new LwPolylineVertex(v25));
                            Arc3.Vertexes.Add(new LwPolylineVertex(v24));
                            Arc3.Vertexes[0].Bulge = 1;
                            fun.PolyFill(dxf, Arc3, 0.3, contour);
                            Vector2[] Line21 = { new Vector2(0, -mhd + dah / 2), new Vector2((v22.X + v23.X) / 2, -mhd + dah / 2) };
                            fun.drawPlinetype(dxf, Line21, 0.15, refin, Linetype.Dashed);
                            Vector2[] Line22 = { new Vector2(0, -mhd - dah / 2), new Vector2((v22.X + v23.X) / 2, -mhd - dah / 2) };
                            fun.drawPlinetype(dxf, Line22, 0.15, refin, Linetype.Dashed);
                            Vector2[] Line23 = { new Vector2(-2, (v23.Y + v24.Y) / 2), new Vector2(v23.X + 2, (v23.Y + v24.Y) / 2) };
                            fun.drawPlinetype(dxf, Line23, 0.15, centre, Linetype.Center);
                            Vector2[] Line24 = { v26, v27 };
                            fun.drawBLine(dxf, Line24, 0.3, contour);
                        }
                        else if (hf < 25 * scale)
                        {
                            double kn0001 = (b - dah / 2 / Math.Cos(mha)) / 2;
                            Vector2 v22 = new Vector2(b - (b - kn0001) * Math.Cos(mha) * Math.Sin(mha) - (dah - adjrg) / 2, -mhd + adjrg / 2);
                            Vector2 v23 = new Vector2(v22.X + dah - adjrg, v22.Y);
                            Vector2 v24 = new Vector2(v23.X, -mhd - adjrg / 2);
                            Vector2 v25 = new Vector2(v22.X, v24.Y);
                            Vector2 v26 = new Vector2(v22.X * 2 + dah - adjrg - v6.X, v7.Y);
                            Vector2 v27 = new Vector2(v26.X, v6.Y);
                            Vector2[] Line19 = { v22, v25 };
                            fun.drawBLine(dxf, Line19, 0.3, contour);
                            Vector2[] Line20 = { v23, v24 };
                            fun.drawBLine(dxf, Line20, 0.3, contour);
                            LwPolyline Arc2 = new LwPolyline();
                            Arc2.Vertexes.Add(new LwPolylineVertex(v23));
                            Arc2.Vertexes.Add(new LwPolylineVertex(v22));
                            Arc2.Vertexes[0].Bulge = 1;
                            fun.PolyFill(dxf, Arc2, 0.3, contour);
                            LwPolyline Arc3 = new LwPolyline();
                            Arc3.Vertexes.Add(new LwPolylineVertex(v25));
                            Arc3.Vertexes.Add(new LwPolylineVertex(v24));
                            Arc3.Vertexes[0].Bulge = 1;
                            fun.PolyFill(dxf, Arc3, 0.3, contour);
                            Vector2[] Line21 = { new Vector2(0, -mhd + dah / 2), new Vector2((v22.X + v23.X) / 2, -mhd + dah / 2) };
                            fun.drawPlinetype(dxf, Line21, 0.15, refin, Linetype.Dashed);
                            Vector2[] Line22 = { new Vector2(0, -mhd - dah / 2), new Vector2((v22.X + v23.X) / 2, -mhd - dah / 2) };
                            fun.drawPlinetype(dxf, Line22, 0.15, refin, Linetype.Dashed);
                            Vector2[] Line23 = { new Vector2(-2, (v23.Y + v24.Y) / 2), new Vector2(v23.X + 2, (v23.Y + v24.Y) / 2) };
                            fun.drawPlinetype(dxf, Line23, 0.15, centre, Linetype.Center);
                            Vector2[] Line24 = { v26, v27 };
                            fun.drawBLine(dxf, Line24, 0.3, contour);
                        }
                        else
                        {
                            double kn0001 = (b - dah / 2 / Math.Cos(mha)) / 2;
                            Vector2 v22 = new Vector2(b - (b - kn0001) * Math.Cos(mha) * Math.Sin(mha) - (dah - adjrg) / 2, -mhd + adjrg / 2);
                            Vector2 v23 = new Vector2(v22.X + dah - adjrg, v22.Y);
                            Vector2 v24 = new Vector2(v23.X, -mhd - adjrg / 2);
                            Vector2 v25 = new Vector2(v22.X, v24.Y);
                            Vector2 v26 = new Vector2(v22.X * 2 + dah - adjrg - v6.X, v7.Y);
                            Vector2 v27 = new Vector2(v26.X, v6.Y);
                            Vector2 v28 = new Vector2(v22.X, -mhd - mhd2 + adjrg / 2);
                            Vector2 v29 = new Vector2(v23.X, v28.Y);
                            Vector2 v30 = new Vector2(v29.X, -mhd - mhd2 - adjrg / 2);
                            Vector2 v31 = new Vector2(v28.X, v30.Y);
                            Vector2[] Line19 = { v22, v25 };
                            fun.drawBLine(dxf, Line19, 0.3, contour);
                            Vector2[] Line20 = { v23, v24 };
                            fun.drawBLine(dxf, Line20, 0.3, contour);
                            LwPolyline Arc2 = new LwPolyline();
                            Arc2.Vertexes.Add(new LwPolylineVertex(v23));
                            Arc2.Vertexes.Add(new LwPolylineVertex(v22));
                            Arc2.Vertexes[0].Bulge = 1;
                            fun.PolyFill(dxf, Arc2, 0.3, contour);
                            LwPolyline Arc3 = new LwPolyline();
                            Arc3.Vertexes.Add(new LwPolylineVertex(v25));
                            Arc3.Vertexes.Add(new LwPolylineVertex(v24));
                            Arc3.Vertexes[0].Bulge = 1;
                            fun.PolyFill(dxf, Arc3, 0.3, contour);
                            Vector2[] Line21 = { new Vector2(0, -mhd + dah / 2), new Vector2((v22.X + v23.X) / 2, -mhd + dah / 2) };
                            fun.drawPlinetype(dxf, Line21, 0.15, refin, Linetype.Dashed);
                            Vector2[] Line22 = { new Vector2(0, -mhd - dah / 2), new Vector2((v22.X + v23.X) / 2, -mhd - dah / 2) };
                            fun.drawPlinetype(dxf, Line22, 0.15, refin, Linetype.Dashed);
                            Vector2[] Line23 = { new Vector2(-2, (v23.Y + v24.Y) / 2), new Vector2(v23.X + 2, (v23.Y + v24.Y) / 2) };
                            fun.drawPlinetype(dxf, Line23, 0.15, centre, Linetype.Center);
                            Vector2[] Line24 = { v26, v27 };
                            fun.drawBLine(dxf, Line24, 0.3, contour);
                            Vector2[] Line25 = { v28, v31 };
                            fun.drawBLine(dxf, Line25, 0.3, contour);
                            Vector2[] Line26 = { v29, v30 };
                            fun.drawBLine(dxf, Line26, 0.3, contour);
                            LwPolyline Arc4 = new LwPolyline();
                            Arc4.Vertexes.Add(new LwPolylineVertex(v29));
                            Arc4.Vertexes.Add(new LwPolylineVertex(v28));
                            Arc4.Vertexes[0].Bulge = 1;
                            fun.PolyFill(dxf, Arc4, 0.3, contour);
                            LwPolyline Arc5 = new LwPolyline();
                            Arc5.Vertexes.Add(new LwPolylineVertex(v31));
                            Arc5.Vertexes.Add(new LwPolylineVertex(v30));
                            Arc5.Vertexes[0].Bulge = 1;
                            fun.PolyFill(dxf, Arc5, 0.3, contour);
                            Vector2[] Line27 = { new Vector2(0, -mhd - mhd2 + dah / 2), new Vector2((v22.X + v23.X) / 2, -mhd - mhd2 + dah / 2) };
                            fun.drawPlinetype(dxf, Line27, 0.15, refin, Linetype.Dashed);
                            Vector2[] Line28 = { new Vector2(0, -mhd - mhd2 - dah / 2), new Vector2((v22.X + v23.X) / 2, -mhd - mhd2 - dah / 2) };
                            fun.drawPlinetype(dxf, Line28, 0.15, refin, Linetype.Dashed);
                            Vector2[] Line29 = { new Vector2(-2, (v29.Y + v30.Y) / 2), new Vector2(v23.X + 2, (v29.Y + v30.Y) / 2) };
                            fun.drawPlinetype(dxf, Line29, 0.15, centre, Linetype.Center);
                        }
                        //标注样式
                        //箭头样式
                        DimensionStyle dimensionStyle = fun.CreateDimStyle();
                        dimensionStyle.ArrowSize = 0.2;
                        dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                        dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                        //文本样式
                        dimensionStyle.TextHeight = 1.0;
                        double offset = 10;
                        //线段尺寸标注
                        //尺寸1
                        LinearDimension dim1 = new LinearDimension(new Line(v12, v7), offset * 2 + v8.X - (v7.X + v12.X) / 2, 270, dimensionStyle);
                        dim1.UserText = "LH = " + Math.Round(lh / scale, 2);
                        dxf.AddEntity(dim1);
                        //尺寸2
                        LinearDimension dim2 = new LinearDimension(new Line(v15, v12), -offset - (v15.Y - v12.Y) / 2, 0, dimensionStyle);
                        dim2.UserText = "WF = " + Math.Round(wf / scale, 2);
                        dxf.AddEntity(dim2);
                        //尺寸3
                        LinearDimension dim3 = new LinearDimension(new Line(new Vector2((v1.X + v2.X) / 2, 0), v12), offset * 3 + v8.X - (v12.X + (v1.X + v2.X) / 2) / 2, 270, dimensionStyle);
                        dim3.UserText = "LF = " + Math.Round(lf / scale, 2);
                        dxf.AddEntity(dim3);
                        //尺寸4
                        if (hf < 16 * scale)
                        {
                            LinearDimension dim4 = new LinearDimension(new Line(new Vector2((b - mhh * Math.Tan(mha)) / (1 + Math.Tan(mha) * Math.Tan(mha)) + (dah - adjrg) / 2 + 2, -mhd), new Vector2((v1.X + v2.X) / 2, 0)), offset + v6.X - ((b - mhh * Math.Tan(mha)) / (1 + Math.Tan(mha) * Math.Tan(mha)) + (dah - adjrg) / 2 + 2 + (v2.X + v1.X) / 2) / 2, 270, dimensionStyle);
                            dim4.UserText = "MHD = " + Math.Round(mhd / scale, 2);
                            dxf.AddEntity(dim4);
                        }
                        if (hf >= 16 * scale)
                        {
                            LinearDimension dim4 = new LinearDimension(new Line(new Vector2(b - (b - (b - dah / 2 / Math.Cos(mha)) / 2) * Math.Cos(mha) * Math.Sin(mha) + (dah - adjrg) / 2 + 2, -mhd), new Vector2((v1.X + v2.X) / 2, 0)), offset + v6.X - (b - (b - (b - dah / 2 / Math.Cos(mha)) / 2) * Math.Cos(mha) * Math.Sin(mha) + (dah - adjrg) / 2 + 2 + (v2.X + v1.X) / 2) / 2, 270, dimensionStyle);
                            dim4.UserText = "MHD = " + Math.Round(mhd / scale, 2);
                            dxf.AddEntity(dim4);
                        }
                        //尺寸5
                        if (hf >= 25 * scale)
                        {
                            LinearDimension dim5 = new LinearDimension(new Line(new Vector2(b - (b - (b - dah / 2 / Math.Cos(mha)) / 2) * Math.Cos(mha) * Math.Sin(mha) + (dah - adjrg) / 2 + 2, -mhd), new Vector2(b - (b - (b - dah / 2 / Math.Cos(mha)) / 2) * Math.Cos(mha) * Math.Sin(mha) + (dah - adjrg) / 2 + 2, -mhd - mhd2)), offset + v6.X - (b - (b - (b - dah / 2 / Math.Cos(mha)) / 2) * Math.Cos(mha) * Math.Sin(mha) + (dah - adjrg) / 2 + 2), 270, dimensionStyle);
                            dim5.UserText = "MHD2 = " + Math.Round(mhd2 / scale, 2);
                            dxf.AddEntity(dim5);
                        }
                        //尺寸6
                        LinearDimension dim6 = new LinearDimension(new Line(new Vector2(b / 2, 0), v7), offset * 2 + (v7.X - b / 2) / 2, 270, dimensionStyle);
                        dim6.UserText = "LS = " + Math.Round(ls / scale, 2);
                        dxf.AddEntity(dim6);
                        //尺寸11
                        Angular2LineDimension angdim11 = new Angular2LineDimension(new Line(v12, v11), new Line(v12, new Vector2(v12.X + l, v12.Y)), Math.Abs(v8.X - v12.X), dimensionStyle);
                        angdim11.UserText = "KAPR = " + Math.Round(kapr / pi * 180, 2) + "°";
                        dxf.AddEntity(angdim11);
                        //尺寸13
                        Angular2LineDimension angdim13 = new Angular2LineDimension(new Line(v12, v13), new Line(v12, v11), offset + l * 2 * Math.Cos(epsr / 2), dimensionStyle);
                        angdim13.UserText = "EPSR = " + Math.Round(epsr / pi * 180, 2) + "°";
                        dxf.AddEntity(angdim13);
                        //尺寸7
                        LinearDimension dim7 = new LinearDimension(new Line(v13, v10), offset, kapr / pi * 180, dimensionStyle);
                        dim7.UserText = "L = " + Math.Round(l / scale, 2);
                        dxf.AddEntity(dim7);
                        //尺寸8
                        LinearDimension dim8 = new LinearDimension(new Line(new Vector2((v1.X + v2.X) / 2, 0), v18), -offset - b / 4, 270, dimensionStyle);
                        dim8.UserText = "ASP = " + Math.Round(asp / scale, 2);
                        dxf.AddEntity(dim8);
                        //尺寸9
                        if (hf < 16 * scale)
                        {
                            LinearDimension dim9 = new LinearDimension(new Line(new Vector2((b - mhh * Math.Tan(mha)) / (1 + Math.Tan(mha) * Math.Tan(mha)) + (dah - adjrg) / 2, -mhd + adjrg / 2), new Vector2((b - mhh * Math.Tan(mha)) / (1 + Math.Tan(mha) * Math.Tan(mha)) + (dah - adjrg) / 2, -mhd - adjrg / 2)), -offset - ((b - mhh * Math.Tan(mha)) / (1 + Math.Tan(mha) * Math.Tan(mha)) + (dah - adjrg) / 2), 270, dimensionStyle);
                            dim9.UserText = "ADJRG = " + Math.Round(adjrg / scale, 2);
                            dxf.AddEntity(dim9);
                        }
                        if (hf >= 16 * scale)
                        {
                            LinearDimension dim9 = new LinearDimension(new Line(new Vector2(b - (b - ((b - dah / 2 / Math.Cos(mha)) / 2)) * Math.Cos(mha) * Math.Sin(mha) + (dah - adjrg) / 2, -mhd + adjrg / 2), new Vector2(b - (b - ((b - dah / 2 / Math.Cos(mha)) / 2)) * Math.Cos(mha) * Math.Sin(mha) + (dah - adjrg) / 2, -mhd - adjrg / 2)), -offset - (b - (b - ((b - dah / 2 / Math.Cos(mha)) / 2)) * Math.Cos(mha) * Math.Sin(mha) + (dah - adjrg) / 2), 270, dimensionStyle);
                            dim9.UserText = "ADJRG = " + Math.Round(adjrg / scale, 2);
                            dxf.AddEntity(dim9);
                        }
                    }
                }
                if (ceatc == "S")//侧切
                {
                    if (sc == "T")//三角形刀片
                    {

                    }
                    else//菱形刀片
                    {
                        double l = ic / Math.Sin(epsr);
                        Vector2 v1 = new Vector2(b / 2 - dk / 2, -dk / 4);
                        Vector2 v2 = new Vector2(b / 2 + dk / 2, v1.Y);
                        Vector2 v3 = new Vector2(v2.X, -k);
                        Vector2 v4 = new Vector2(b / 2 + td / 2, v3.Y);
                        Vector2 v5 = new Vector2(v4.X, -asp);
                        Vector2 v6 = new Vector2(b, v5.Y);
                        Vector2 v7 = new Vector2(v6.X, -ls);
                        Vector2 v12 = new Vector2(wf, -lf);
                        Vector2 v0 = new Vector2(v12.X - s * Math.Tan(an) * Math.Cos(pi - kapr - epsr / 2) / Math.Sin(epsr / 2), v12.Y + s * Math.Tan(an) * Math.Sin(pi - kapr - epsr / 2) / Math.Sin(epsr / 2));
                        Vector2 v11 = new Vector2(v12.X + l * Math.Cos(kapr), v12.Y + l * Math.Sin(kapr));
                        Vector2 v13 = new Vector2(v12.X - l * Math.Cos(pi - kapr - epsr), v12.Y + l * Math.Sin(pi - kapr - epsr));
                        Vector2 v10 = new Vector2(v11.X - l * Math.Cos(pi - kapr - epsr), v11.Y + l * Math.Sin(pi - kapr - epsr));
                        Vector2 v9 = new Vector2(v11.X - s * Math.Tan(an) * Math.Cos(pi - kapr - epsr) / Math.Sin(epsr), v11.Y + s * Math.Tan(an) * Math.Sin(pi - kapr - epsr) / Math.Sin(epsr));
                        Vector2 v14 = new Vector2(v13.X + s * Math.Tan(an) * Math.Cos(kapr) / Math.Sin(epsr), v13.Y + s * Math.Tan(an) * Math.Sin(kapr) / Math.Sin(epsr));
                        Vector2 v8 = new Vector2(((v0.X * Math.Tan(kapr) * Math.Tan(hea) + v7.X + v7.Y * Math.Tan(hea)) - v0.Y * Math.Tan(hea)) / (1 + Math.Tan(kapr) * Math.Tan(hea)), (((v0.X * Math.Tan(kapr) * Math.Tan(hea) + v7.X + v7.Y * Math.Tan(hea)) - v0.Y * Math.Tan(hea)) / (1 + Math.Tan(kapr) * Math.Tan(hea)) - v0.X) * Math.Tan(kapr) + v0.Y);
                        Vector2 v15 = new Vector2(0, v0.Y + v0.X * Math.Tan(pi - kapr - epsr));
                        Vector2 v16 = new Vector2(0, v8.Y);
                        Vector2 v17 = new Vector2(0, v7.Y);
                        Vector2 v18 = new Vector2(0, v6.Y);
                        Vector2 v19 = new Vector2(b / 2 - td / 2, v5.Y);
                        Vector2 v20 = new Vector2(v19.X, v4.Y);
                        Vector2 v21 = new Vector2(v1.X, v3.Y);
                        //线段
                        Vector2[] Line1 = { v1, v2 };
                        fun.drawBLine(dxf, Line1, 0.3, contour);
                        Vector2[] Line2 = { v2, v3 };
                        fun.drawBLine(dxf, Line2, 0.3, contour);
                        Vector2[] Line3 = { v3, v21 };
                        fun.drawBLine(dxf, Line3, 0.3, contour);
                        Vector2[] Line4 = { v21, v1 };
                        fun.drawBLine(dxf, Line4, 0.3, contour);
                        Vector2[] Line5 = { v4, v5 };
                        fun.drawBLine(dxf, Line5, 0.3, contour);
                        Vector2[] Line6 = { v19, v20 };
                        fun.drawBLine(dxf, Line6, 0.3, contour);
                        Vector2[] Line7 = { v6, v18 };
                        fun.drawBLine(dxf, Line7, 0.3, contour);
                        Vector2[] Line8 = { v6, v7 };
                        fun.drawBLine(dxf, Line8, 0.3, contour);
                        Vector2[] Line9 = { v7, v17 };
                        fun.drawBLine(dxf, Line9, 0.3, contour);
                        Vector2[] Line10 = { v7, v8 };
                        fun.drawBLine(dxf, Line10, 0.3, contour);
                        Vector2[] Line11 = { v8, v16 };
                        fun.drawBLine(dxf, Line11, 0.3, contour);
                        Vector2[] Line12 = { v8, v9 };
                        fun.drawBLine(dxf, Line12, 0.3, contour);
                        Vector2[] Line13 = { v10, v11 };
                        fun.drawBLine(dxf, Line13, 0.3, contour);
                        Vector2[] Line14 = { v11, v12 };
                        fun.drawBLine(dxf, Line14, 0.3, contour);
                        Vector2[] Line15 = { v12, v13 };
                        fun.drawBLine(dxf, Line15, 0.3, contour);
                        Vector2[] Line16 = { v13, v10 };
                        fun.drawBLine(dxf, Line16, 0.3, contour);
                        Vector2[] Line17 = { v14, v15 };
                        fun.drawBLine(dxf, Line17, 0.3, contour);
                        Vector2[] Line18 = { v15, v18 };
                        fun.drawBLine(dxf, Line18, 0.3, contour);
                        LwPolyline Arc1 = new LwPolyline();
                        Arc1.Vertexes.Add(new LwPolylineVertex(v2));
                        Arc1.Vertexes.Add(new LwPolylineVertex(v1));
                        Arc1.Vertexes[0].Bulge = dk / 2 / (v2.X - v1.X);
                        fun.PolyFill(dxf, Arc1, 0.3, contour);
                        if (hf < 16 * scale)
                        {
                            Vector2 v22 = new Vector2((b - mhh * Math.Tan(mha)) / (1 + Math.Tan(mha) * Math.Tan(mha)) - (dah - adjrg) / 2, -mhd + adjrg / 2);
                            Vector2 v23 = new Vector2(v22.X + dah - adjrg, v22.Y);
                            Vector2 v24 = new Vector2(v23.X, -mhd - adjrg / 2);
                            Vector2 v25 = new Vector2(v22.X, v24.Y);
                            Vector2 v26 = new Vector2(v22.X * 2 + dah - adjrg - v6.X, v7.Y);
                            Vector2 v27 = new Vector2(v26.X, v6.Y);
                            Vector2[] Line19 = { v22, v25 };
                            fun.drawBLine(dxf, Line19, 0.3, contour);
                            Vector2[] Line20 = { v23, v24 };
                            fun.drawBLine(dxf, Line20, 0.3, contour);
                            LwPolyline Arc2 = new LwPolyline();
                            Arc2.Vertexes.Add(new LwPolylineVertex(v23));
                            Arc2.Vertexes.Add(new LwPolylineVertex(v22));
                            Arc2.Vertexes[0].Bulge = 1;
                            fun.PolyFill(dxf, Arc2, 0.3, contour);
                            LwPolyline Arc3 = new LwPolyline();
                            Arc3.Vertexes.Add(new LwPolylineVertex(v25));
                            Arc3.Vertexes.Add(new LwPolylineVertex(v24));
                            Arc3.Vertexes[0].Bulge = 1;
                            fun.PolyFill(dxf, Arc3, 0.3, contour);
                            Vector2[] Line21 = { new Vector2(0, -mhd + dah / 2), new Vector2((v22.X + v23.X) / 2, -mhd + dah / 2) };
                            fun.drawPlinetype(dxf, Line21, 0.15, refin, Linetype.Dashed);
                            Vector2[] Line22 = { new Vector2(0, -mhd - dah / 2), new Vector2((v22.X + v23.X) / 2, -mhd - dah / 2) };
                            fun.drawPlinetype(dxf, Line22, 0.15, refin, Linetype.Dashed);
                            Vector2[] Line23 = { new Vector2(-2, (v23.Y + v24.Y) / 2), new Vector2(v23.X + 2, (v23.Y + v24.Y) / 2) };
                            fun.drawPlinetype(dxf, Line23, 0.15, centre, Linetype.Center);
                            Vector2[] Line24 = { v26, v27 };
                            fun.drawBLine(dxf, Line24, 0.3, contour);
                        }
                        else if (hf < 25 * scale)
                        {
                            double kn0001 = (b - dah / 2 / Math.Cos(mha)) / 2;
                            Vector2 v22 = new Vector2(b - (b - kn0001) * Math.Cos(mha) * Math.Sin(mha) - (dah - adjrg) / 2, -mhd + adjrg / 2);
                            Vector2 v23 = new Vector2(v22.X + dah - adjrg, v22.Y);
                            Vector2 v24 = new Vector2(v23.X, -mhd - adjrg / 2);
                            Vector2 v25 = new Vector2(v22.X, v24.Y);
                            Vector2 v26 = new Vector2(v22.X * 2 + dah - adjrg - v6.X, v7.Y);
                            Vector2 v27 = new Vector2(v26.X, v6.Y);
                            Vector2[] Line19 = { v22, v25 };
                            fun.drawBLine(dxf, Line19, 0.3, contour);
                            Vector2[] Line20 = { v23, v24 };
                            fun.drawBLine(dxf, Line20, 0.3, contour);
                            LwPolyline Arc2 = new LwPolyline();
                            Arc2.Vertexes.Add(new LwPolylineVertex(v23));
                            Arc2.Vertexes.Add(new LwPolylineVertex(v22));
                            Arc2.Vertexes[0].Bulge = 1;
                            fun.PolyFill(dxf, Arc2, 0.3, contour);
                            LwPolyline Arc3 = new LwPolyline();
                            Arc3.Vertexes.Add(new LwPolylineVertex(v25));
                            Arc3.Vertexes.Add(new LwPolylineVertex(v24));
                            Arc3.Vertexes[0].Bulge = 1;
                            fun.PolyFill(dxf, Arc3, 0.3, contour);
                            Vector2[] Line21 = { new Vector2(0, -mhd + dah / 2), new Vector2((v22.X + v23.X) / 2, -mhd + dah / 2) };
                            fun.drawPlinetype(dxf, Line21, 0.15, refin, Linetype.Dashed);
                            Vector2[] Line22 = { new Vector2(0, -mhd - dah / 2), new Vector2((v22.X + v23.X) / 2, -mhd - dah / 2) };
                            fun.drawPlinetype(dxf, Line22, 0.15, refin, Linetype.Dashed);
                            Vector2[] Line23 = { new Vector2(-2, (v23.Y + v24.Y) / 2), new Vector2(v23.X + 2, (v23.Y + v24.Y) / 2) };
                            fun.drawPlinetype(dxf, Line23, 0.15, centre, Linetype.Center);
                            Vector2[] Line24 = { v26, v27 };
                            fun.drawBLine(dxf, Line24, 0.3, contour);
                        }
                        else
                        {
                            double kn0001 = (b - dah / 2 / Math.Cos(mha)) / 2;
                            Vector2 v22 = new Vector2(b - (b - kn0001) * Math.Cos(mha) * Math.Sin(mha) - (dah - adjrg) / 2, -mhd + adjrg / 2);
                            Vector2 v23 = new Vector2(v22.X + dah - adjrg, v22.Y);
                            Vector2 v24 = new Vector2(v23.X, -mhd - adjrg / 2);
                            Vector2 v25 = new Vector2(v22.X, v24.Y);
                            Vector2 v26 = new Vector2(v22.X * 2 + dah - adjrg - v6.X, v7.Y);
                            Vector2 v27 = new Vector2(v26.X, v6.Y);
                            Vector2 v28 = new Vector2(v22.X, -mhd - mhd2 + adjrg / 2);
                            Vector2 v29 = new Vector2(v23.X, v28.Y);
                            Vector2 v30 = new Vector2(v29.X, -mhd - mhd2 - adjrg / 2);
                            Vector2 v31 = new Vector2(v28.X, v30.Y);
                            Vector2[] Line19 = { v22, v25 };
                            fun.drawBLine(dxf, Line19, 0.3, contour);
                            Vector2[] Line20 = { v23, v24 };
                            fun.drawBLine(dxf, Line20, 0.3, contour);
                            LwPolyline Arc2 = new LwPolyline();
                            Arc2.Vertexes.Add(new LwPolylineVertex(v23));
                            Arc2.Vertexes.Add(new LwPolylineVertex(v22));
                            Arc2.Vertexes[0].Bulge = 1;
                            fun.PolyFill(dxf, Arc2, 0.3, contour);
                            LwPolyline Arc3 = new LwPolyline();
                            Arc3.Vertexes.Add(new LwPolylineVertex(v25));
                            Arc3.Vertexes.Add(new LwPolylineVertex(v24));
                            Arc3.Vertexes[0].Bulge = 1;
                            fun.PolyFill(dxf, Arc3, 0.3, contour);
                            Vector2[] Line21 = { new Vector2(0, -mhd + dah / 2), new Vector2((v22.X + v23.X) / 2, -mhd + dah / 2) };
                            fun.drawPlinetype(dxf, Line21, 0.15, refin, Linetype.Dashed);
                            Vector2[] Line22 = { new Vector2(0, -mhd - dah / 2), new Vector2((v22.X + v23.X) / 2, -mhd - dah / 2) };
                            fun.drawPlinetype(dxf, Line22, 0.15, refin, Linetype.Dashed);
                            Vector2[] Line23 = { new Vector2(-2, (v23.Y + v24.Y) / 2), new Vector2(v23.X + 2, (v23.Y + v24.Y) / 2) };
                            fun.drawPlinetype(dxf, Line23, 0.15, centre, Linetype.Center);
                            Vector2[] Line24 = { v26, v27 };
                            fun.drawBLine(dxf, Line24, 0.3, contour);
                            Vector2[] Line25 = { v28, v31 };
                            fun.drawBLine(dxf, Line25, 0.3, contour);
                            Vector2[] Line26 = { v29, v30 };
                            fun.drawBLine(dxf, Line26, 0.3, contour);
                            LwPolyline Arc4 = new LwPolyline();
                            Arc4.Vertexes.Add(new LwPolylineVertex(v29));
                            Arc4.Vertexes.Add(new LwPolylineVertex(v28));
                            Arc4.Vertexes[0].Bulge = 1;
                            fun.PolyFill(dxf, Arc4, 0.3, contour);
                            LwPolyline Arc5 = new LwPolyline();
                            Arc5.Vertexes.Add(new LwPolylineVertex(v31));
                            Arc5.Vertexes.Add(new LwPolylineVertex(v30));
                            Arc5.Vertexes[0].Bulge = 1;
                            fun.PolyFill(dxf, Arc5, 0.3, contour);
                            Vector2[] Line27 = { new Vector2(0, -mhd - mhd2 + dah / 2), new Vector2((v22.X + v23.X) / 2, -mhd - mhd2 + dah / 2) };
                            fun.drawPlinetype(dxf, Line27, 0.15, refin, Linetype.Dashed);
                            Vector2[] Line28 = { new Vector2(0, -mhd - mhd2 - dah / 2), new Vector2((v22.X + v23.X) / 2, -mhd - mhd2 - dah / 2) };
                            fun.drawPlinetype(dxf, Line28, 0.15, refin, Linetype.Dashed);
                            Vector2[] Line29 = { new Vector2(-2, (v29.Y + v30.Y) / 2), new Vector2(v23.X + 2, (v29.Y + v30.Y) / 2) };
                            fun.drawPlinetype(dxf, Line29, 0.15, centre, Linetype.Center);
                        }
                        //标注样式
                        //箭头样式
                        DimensionStyle dimensionStyle = fun.CreateDimStyle();
                        dimensionStyle.ArrowSize = 0.2;
                        dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                        dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                        //文本样式
                        dimensionStyle.TextHeight = 1.0;
                        double offset = 10;
                        //线段尺寸标注
                        //尺寸1
                        LinearDimension dim1 = new LinearDimension(new Line(v12, v7), offset * 2 + v8.X - (v7.X + v12.X) / 2, 270, dimensionStyle);
                        dim1.UserText = "LH = " + Math.Round(lh / scale, 2);
                        dxf.AddEntity(dim1);
                        //尺寸2
                        LinearDimension dim2 = new LinearDimension(new Line(v15, v12), -offset - (v15.Y - v12.Y) / 2, 0, dimensionStyle);
                        dim2.UserText = "WF = " + Math.Round(wf / scale, 2);
                        dxf.AddEntity(dim2);
                        //尺寸3
                        LinearDimension dim3 = new LinearDimension(new Line(new Vector2((v1.X + v2.X) / 2, 0), v12), offset * 3 + v8.X - (v12.X + (v1.X + v2.X) / 2) / 2, 270, dimensionStyle);
                        dim3.UserText = "LF = " + Math.Round(lf / scale, 2);
                        dxf.AddEntity(dim3);
                        //尺寸4
                        if (hf < 16 * scale)
                        {
                            LinearDimension dim4 = new LinearDimension(new Line(new Vector2((b - mhh * Math.Tan(mha)) / (1 + Math.Tan(mha) * Math.Tan(mha)) + (dah - adjrg) / 2 + 2, -mhd), new Vector2((v1.X + v2.X) / 2, 0)), offset + v6.X - ((b - mhh * Math.Tan(mha)) / (1 + Math.Tan(mha) * Math.Tan(mha)) + (dah - adjrg) / 2 + 2 + (v2.X + v1.X) / 2) / 2, 270, dimensionStyle);
                            dim4.UserText = "MHD = " + Math.Round(mhd / scale, 2);
                            dxf.AddEntity(dim4);
                        }
                        if (hf >= 16 * scale)
                        {
                            LinearDimension dim4 = new LinearDimension(new Line(new Vector2(b - (b - (b - dah / 2 / Math.Cos(mha)) / 2) * Math.Cos(mha) * Math.Sin(mha) + (dah - adjrg) / 2 + 2, -mhd), new Vector2((v1.X + v2.X) / 2, 0)), offset + v6.X - (b - (b - (b - dah / 2 / Math.Cos(mha)) / 2) * Math.Cos(mha) * Math.Sin(mha) + (dah - adjrg) / 2 + 2 + (v2.X + v1.X) / 2) / 2, 270, dimensionStyle);
                            dim4.UserText = "MHD = " + Math.Round(mhd / scale, 2);
                            dxf.AddEntity(dim4);
                        }
                        //尺寸5
                        if (hf >= 25 * scale)
                        {
                            LinearDimension dim5 = new LinearDimension(new Line(new Vector2(b - (b - (b - dah / 2 / Math.Cos(mha)) / 2) * Math.Cos(mha) * Math.Sin(mha) + (dah - adjrg) / 2 + 2, -mhd), new Vector2(b - (b - (b - dah / 2 / Math.Cos(mha)) / 2) * Math.Cos(mha) * Math.Sin(mha) + (dah - adjrg) / 2 + 2, -mhd - mhd2)), offset + v6.X - (b - (b - (b - dah / 2 / Math.Cos(mha)) / 2) * Math.Cos(mha) * Math.Sin(mha) + (dah - adjrg) / 2 + 2), 270, dimensionStyle);
                            dim5.UserText = "MHD2 = " + Math.Round(mhd2 / scale, 2);
                            dxf.AddEntity(dim5);
                        }
                        //尺寸6
                        LinearDimension dim6 = new LinearDimension(new Line(new Vector2(b / 2, 0), v7), offset * 2 + (v7.X - b / 2) / 2, 270, dimensionStyle);
                        dim6.UserText = "LS = " + Math.Round(ls / scale, 2);
                        dxf.AddEntity(dim6);
                        //尺寸11
                        Angular2LineDimension angdim11 = new Angular2LineDimension(new Line(v12, v11), new Line(v12, new Vector2(v12.X + l, v12.Y)), Math.Abs(v8.X - v12.X), dimensionStyle);
                        angdim11.UserText = "KAPR = " + Math.Round(kapr / pi * 180, 2) + "°";
                        dxf.AddEntity(angdim11);
                        //尺寸13
                        Angular2LineDimension angdim13 = new Angular2LineDimension(new Line(v12, v13), new Line(v12, v11), offset + l * 2 * Math.Cos(epsr / 2), dimensionStyle);
                        angdim13.UserText = "EPSR = " + Math.Round(epsr / pi * 180, 2) + "°";
                        dxf.AddEntity(angdim13);
                        //尺寸7
                        LinearDimension dim7 = new LinearDimension(new Line(v13, v10), offset, kapr / pi * 180, dimensionStyle);
                        dim7.UserText = "L = " + Math.Round(l / scale, 2);
                        dxf.AddEntity(dim7);
                        //尺寸8
                        LinearDimension dim8 = new LinearDimension(new Line(new Vector2((v1.X + v2.X) / 2, 0), v18), -offset - b / 4, 270, dimensionStyle);
                        dim8.UserText = "ASP = " + Math.Round(asp / scale, 2);
                        dxf.AddEntity(dim8);
                        //尺寸9
                        if (hf < 16 * scale)
                        {
                            LinearDimension dim9 = new LinearDimension(new Line(new Vector2((b - mhh * Math.Tan(mha)) / (1 + Math.Tan(mha) * Math.Tan(mha)) + (dah - adjrg) / 2, -mhd + adjrg / 2), new Vector2((b - mhh * Math.Tan(mha)) / (1 + Math.Tan(mha) * Math.Tan(mha)) + (dah - adjrg) / 2, -mhd - adjrg / 2)), -offset - ((b - mhh * Math.Tan(mha)) / (1 + Math.Tan(mha) * Math.Tan(mha)) + (dah - adjrg) / 2), 270, dimensionStyle);
                            dim9.UserText = "ADJRG = " + Math.Round(adjrg / scale, 2);
                            dxf.AddEntity(dim9);
                        }
                        if (hf >= 16 * scale)
                        {
                            LinearDimension dim9 = new LinearDimension(new Line(new Vector2(b - (b - ((b - dah / 2 / Math.Cos(mha)) / 2)) * Math.Cos(mha) * Math.Sin(mha) + (dah - adjrg) / 2, -mhd + adjrg / 2), new Vector2(b - (b - ((b - dah / 2 / Math.Cos(mha)) / 2)) * Math.Cos(mha) * Math.Sin(mha) + (dah - adjrg) / 2, -mhd - adjrg / 2)), -offset - (b - (b - ((b - dah / 2 / Math.Cos(mha)) / 2)) * Math.Cos(mha) * Math.Sin(mha) + (dah - adjrg) / 2), 270, dimensionStyle);
                            dim9.UserText = "ADJRG = " + Math.Round(adjrg / scale, 2);
                            dxf.AddEntity(dim9);
                        }
                    }
                }
            }
            if (thsc == "S")//直头
            {
                if (ceatc == "E")//端切
                {
                    if (sc == "T")//三角形刀片
                    {

                    }
                    else//菱形刀片
                    {

                    }
                }
                if (ceatc == "S")//侧切
                {
                    if (sc == "T")//三角形刀片
                    {

                    }
                    else//菱形刀片
                    {

                    }
                }
            }
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5 + b / 2, 210 - lf / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
    }
}
